home *** CD-ROM | disk | FTP | other *** search
- Path: keats.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.perl.misc,comp.lang.c
- Subject: Re: PROGRAMERS OF ANY LANGUAGE
- Date: 15 Apr 1996 09:16:17 -0700
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4ktsohINNmt@keats.ugrad.cs.ubc.ca>
- References: <Pine.SOL.3.91.960329010021.13209A-100000@harvey> <4krg5h$7tt@nntp1.best.com> <4krrccINN78i@keats.ugrad.cs.ubc.ca> <4ksfaq$jug@nntp1.best.com>
- NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
-
- In article <4ksfaq$jug@nntp1.best.com>, Zenin <zenin@best.com> wrote:
- >Kazimir Kylheku <c2a192@ugrad.cs.ubc.ca> wrote:
- > >snip<
- >: Actually I do program much. I wouldn't talk if I were you, read on...
- > Hmm, didn't see my simily did you? Oh well...
- > >snip<
- >: In your if statement, the else clause gets executed if *any one* of the
- >: test expressions fails! ``if (1 && 1 && 0)'' will launch into the *else* clause.
- >: In MY if statement, the else clause only gets executed it the *outermost* test
- >: condition fails. ``if (1) if (1) if (0) statement 1; else statement2;'' will
- >: cause *neither* statement1 *nor* statement2 to be executed!
- > There are ways around this as well, however simply taking the 10
- > secs of time to add the }{s as your past example did would be the
- > easyest way in Perl.
- >
- >: See, the two are not equivalent at all!
- > You're right, and that teaches me to followup after a double
- > espresso. ;-}
-
- Same with me: a dangling else in C is taken to be the innermost case, not the
- outermost. In LR parser lingo, it is resolved by doing a shift, not a reduce,
- which causes the innermost else clause to be ``stacked'' with the nearest
- matching if. This is the most common resolution of the ambiguity. The yacc
- parser generator reflects this thinking---in the case of a shift/reduce
- ambiguity in the grammar, it emits a warning, and generates a parser that will
- do the shift.
-
- Thus my bracketing of the original C program was as incorrect as your attempt
- to make an equivalent single if using the and operator.
-
- Make that two double espressos.
- --
- I'm not really a jerk, but I play one on Usenet.
-